// js api
// @Link  https://github.com/huagelong/devinggo
// @Copyright  Copyright (c) 2024 devinggo
// @Author  Kai <hpuwang@gmail.com>
// @License  https://github.com/huagelong/devinggo/blob/master/LICENSE

import { request } from '@/utils/request.js'

export default {
{% if eq .table.Type "single"  %}
/**
* 获取{% .tableCaseCamelLowerName %}分页列表
* @returns
*/
getPageList (params = {}) {
    return request({
        url: '{% .requestRoute %}/index',
        method: 'get',
        params
    })
},

getList (params = {}) {
    return request({
        url: '{% .requestRoute %}/list',
        method: 'get',
        params
    })
},

{% end %}

{% if eq .table.Type "tree"  %}
/**
* 获取{% .tableCaseCamelLowerName %}列表
* @returns
*/
getPageList (params = {}) {
    return request({
        url: '{% .requestRoute %}/index',
        method: 'get',
        params
    })
},

/**
* 获取{% .tableCaseCamelLowerName %}选择树
* @returns
*/
tree () {
    return request({
        url: '{% .requestRoute %}/tree',
        method: 'get'
    })
},

{% end %}

{% if contains .generateMenus "recycle"  %}
/**
* 从回收站获取{% .tableCaseCamelLowerName %}数据列表
* @returns
*/
getPageRecycleList (params = {}) {
    return request({
        url: '{% .requestRoute %}/recycle',
        method: 'get',
        params
    })
},

getRecycleList (params = {}) {
    return request({
        url: '{% .requestRoute %}/recycleList',
        method: 'get',
        params
    })
},

/**
* 恢复{% .tableCaseCamelLowerName %}数据
* @returns
*/
recoverys (data) {
    return request({
        url: '{% .requestRoute %}/recovery',
        method: 'put',
        data
    })
},

/**
* 真实删除{% .tableCaseCamelLowerName %}
* @returns
*/
realDeletes (data) {
    return request({
        url: '{% .requestRoute %}/realDelete',
        method: 'delete',
        data
    })
},
{% end %}


{% if contains .generateMenus "save"  %}
/**
* 添加{% .tableCaseCamelLowerName %}
* @returns
*/
save (data = {}) {
    return request({
        url: '{% .requestRoute %}/save',
        method: 'post',
        data
    })
},
{% end %}
{% if contains .generateMenus "update"  %}
/**
* 更新{% .tableCaseCamelLowerName %}数据
* @returns
*/
update (id, data = {}) {
    return request({
        url: '{% .requestRoute %}/update/' + id,
        method: 'put',
        data
    })
},
{% end %}
{% if contains .generateMenus "read"  %}
/**
* 读取{% .tableCaseCamelLowerName %}
* @returns
*/
read (id) {
    return request({
        url: '{% .requestRoute %}/read/' + id,
        method: 'get'
    })
},
{% end %}

{% if contains .generateMenus "delete"  %}
/**
* 将{% .tableCaseCamelLowerName %}删除，有软删除则移动到回收站
* @returns
*/
deletes (data) {
    return request({
        url: '{% .requestRoute %}/delete',
        method: 'delete',
        data
    })
},
{% end %}

{% if contains .generateMenus "changeStatus"  %}
/**
* 更改{% .tableCaseCamelLowerName %}数据
* @returns
*/
changeStatus (data = {}) {
    return request({
        url: '{% .requestRoute %}/changeStatus',
        method: 'put',
        data
    })
},
{% end %}

{% if contains .generateMenus "numberOperation"  %}
/**
* 修改{% .tableCaseCamelLowerName %}数值数据，自增自减
* @returns
*/
numberOperation (data = {}) {
    return request({
        url: '{% .requestRoute %}/numberOperation',
        method: 'put',
        data
    })
},
{% end %}

{% if contains .generateMenus "import"  %}
/**
* {% .tableCaseCamelLowerName %}导入
* @returns
*/
importExcel (data = {}) {
    return request({
        url: '{% .requestRoute %}/import',
        method: 'post',
        data
    })
},

/**
* {% .tableCaseCamelLowerName %}下载模板
* @returns
*/
downloadTemplate () {
    return request({
        url: '{% .requestRoute %}/downloadTemplate',
        method: 'post',
        responseType: 'blob'
    })
},
{% end %}

{% if contains .generateMenus "export"  %}
/**
* {% .tableCaseCamelLowerName %}导出
* @returns
*/
exportExcel (params = {}) {
    return request({
        url: '{% .requestRoute %}/export',
        method: 'post',
        responseType: 'blob',
        params
    })
},
{% end %}

}